package com.googlecode.milib.display {
	import com.googlecode.milib.base.MLBaseClass;
	import com.googlecode.milib.util.MLBitmapUtil;

	import flash.display.MovieClip;

	/**
	 * @author Marek Brun
	 */
	public class PatternClip extends MLBaseClass {
		
		private var _mc:MovieClip;
		private var mc_bmp:MovieClip;
		private var repeat:RepeatBitmap;
		
		public function PatternClip(mc:MovieClip) {
			_mc=mc;
			dbg.registerInDisplay(mc);
			
			mc_bmp=MovieClip(mc.bmp);
			repeat=new RepeatBitmap();
			repeat.setSourceBitmapData(MLBitmapUtil.getBitmapDataByDisplay(mc_bmp));
			mc.removeChild(mc_bmp);
			mc.addChild(repeat);
			
		}
		
		public function setSize(width:Number=-1, height:Number=-1):void {
			repeat.setSize(
				width==-1 ? mc_bmp.width : width,
				height==-1 ? mc_bmp.height : height
			);
		}
		
		public function get mc():MovieClip { return _mc; }
		
	}
}
